package com.world.rickcloudendpoint.service.net.tcp.client;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;

/**
 * @description: 配置 netty client
 * @author: jlsong
 * @date: 2021/12/07 00:11:27
 * @version: 1.0
 */
public class TransmissionChannelInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {

        // 添加解码器
        socketChannel.pipeline().addLast("decoder", new StringDecoder());
        // 添加编码器
        socketChannel.pipeline().addLast("encoder", new StringEncoder());
        // 添加自定义处理器
        socketChannel.pipeline().addLast(new TransmissionChannelHandler());
    }
}
